package crm.implementor;

import crm.daoInterfaces.CampaignCustomerDao;
import crm.dbhandelling.Crude;
import crm.dto.CampaignCustomer;


public class CampaignCustomerImp extends Crude implements CampaignCustomerDao
{

	private String className=new CampaignCustomer().getClass().getName();
	@Override
	public void add(CampaignCustomer cc) throws Exception 
	{
		
		super.insert(cc);
	}

	@Override
	public void update(CampaignCustomer cc) {
		
		
		super.update(className, "customerId", cc.getCustomerId()+"", "id", cc.getAutoId()+"");
		super.update(className, "campaignId", cc.getCampaignId()+"", "id", cc.getAutoId()+"");
		
	}

	@Override
	public void delete(CampaignCustomer cc) {
		
		super.delete(className, "id", cc.getAutoId()+"");
		
	}

	@Override
	public CampaignCustomer retrieve( String conditionField,
			String conditionValue) throws Exception {
		
		CampaignCustomer c=(CampaignCustomer) super.retreive(className, conditionField, conditionValue);
		return c;
	}

	@Override
	public CampaignCustomer[] retrieveArray(
			String conditionField, String conditionValue) throws Exception 
	{
		Object[] att=super.retreiveArrayOnCondition(className, conditionField, conditionValue);
		CampaignCustomer[] s=new CampaignCustomer[att.length];
		for(int i=0;i<s.length;i++)
			s[i]=(CampaignCustomer) att[i];
		return s;
		
		
	}

	@Override
	public CampaignCustomer[] retrieveAll() throws Exception {
		
		Object[] att=super.retreiveAll(className);
		CampaignCustomer[] s=new CampaignCustomer[att.length];
		for(int i=0;i<s.length;i++)
				s[i]=(CampaignCustomer) att[i];
		return s;
		
	}

	
}
